home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / OUI / checkbox.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  1.6 KB  |  59 lines

  1. // $Id: checkbox.cc 1.2 1997/07/14 04:22:34 dlorre Exp dlorre $
  2.  
  3. #include <intuition/gadgetclass.h>
  4. #include <libraries/gadtools.h>
  5.  
  6. #include "gadgets/checkbox.h"
  7. #include "gadgetlist.h"
  8.  
  9. #include <proto/gadtools.h>
  10.  
  11. // ========================================================================
  12. // ==========================  CHECKBOX CLASS =============================
  13. // ========================================================================
  14.  
  15.  
  16. checkbox::checkbox(gadgetlist *gl,
  17.                   void (window::*func)(gadget *, unsigned long, unsigned short),
  18.                   const char *text, long checked, long place, BOOL disable) : gadget(gl, func)
  19. {
  20.     gl->ng->ng_GadgetText = (UBYTE *)text ;
  21.     underkey(text) ;
  22.     gl->ng->ng_Flags = place ;
  23.     cursel = checked ;
  24.  
  25.     gad = gl->gad = CreateGadget(CHECKBOX_KIND, gl->gad, gl->ng,
  26.             GTCB_Checked,   checked,
  27.             GTCB_Scaled,    TRUE,
  28.             GT_Underscore,  '_',
  29.             GA_Disabled,    disable,
  30.             TAG_END) ;
  31. }
  32.  
  33. void checkbox::set(long flag)
  34. {
  35.     cursel = flag ;
  36.     GT_SetGadgetAttrs(gad, w, NULL,
  37.         GTCB_Checked,   flag,
  38.         TAG_DONE) ;
  39. }
  40.  
  41. void checkbox::disable(BOOL flag)
  42. {
  43.     GT_SetGadgetAttrs(gad, w, NULL,
  44.         GA_Disabled,   flag,
  45.         TAG_DONE) ;
  46. }
  47.  
  48. void checkbox::action(unsigned long classe, unsigned short code)
  49. {
  50.     cursel = short(gad->Flags & GFLG_SELECTED) ;
  51.     gadget::action(classe, code) ;
  52. }
  53.  
  54. void checkbox::keystroke(BOOL shifted)
  55. {
  56.     cursel = !cursel ;
  57.     gadget::action(NULL, cursel) ;
  58.     GT_SetGadgetAttrs(gad, w, NULL, GTCB_Checked, cursel, TAG_DONE) ;
  59. }